function StatusAssistant() {
	this.message = {
		model: {
			value: "hi"
		}
	};
	this.appAssistant = Mojo.Controller.getAppController().assistant;
	this.x = this.appAssistant.getClient();
}

StatusAssistant.prototype.updateStatus = function(ev,state) {
	this.$.find('#mobile').html(state.name);
	this.$.find('#browser').html(state.peer ? "CONNECTED" : "DISCONNECTED");
};

StatusAssistant.prototype.sendMessage = function() {
	var msg = this.message.model.value;
	this.message.model.value = "";
	this.x.xmpp('send', msg);
	this.controller.modelChanged(this.message.model);

};

StatusAssistant.prototype.onLogout = function() {
	this.appAssistant.removeCookie();
	this.x.xmpp('disconnect');
	this.appAssistant.handleLaunch({source: 'logout'});
};

StatusAssistant.prototype.onMessage = function(ev, msg) {
	this.$.find('#info').html('message recieved:' + jQuery('body',msg).text());
};

StatusAssistant.prototype.setup = function() {
	this.$ = jQuery(this.controller.document);
	var c = this.controller, e = Mojo.Event;

	this.docId = this.x.xmpp('docs').add(c.document);

	this.x.xmpp('option','controller', this.controller);

	c.setupWidget('send', {}, { label: 'Send' } );
	c.setupWidget('logout', {}, { label: 'Logout' } );
	c.setupWidget('message', {}, this.message.model );

	c.listen(c.get('send'),e.tap, this.sendMessage.bind(this));
	c.listen(c.get('logout'),e.tap, this.onLogout.bind(this));
};

StatusAssistant.prototype.activate = function(event) {
	/* put in event handlers here that should only be in effect when this scene is active. For
	   example, key handlers that are observing the document */
};

StatusAssistant.prototype.deactivate = function(event) {
	/* remove any event handlers you added in activate and do any other cleanup that should happen before
	   this scene is popped or another scene is pushed on top */
};

StatusAssistant.prototype.cleanup = function(event) {
	/* this function should do any cleanup needed before the scene is destroyed as 
	   a result of being popped off the scene stack */

	this.x.xmpp('docs').del(this.docId);
};
